package com.huike.clues.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huike.common.entity.MPTbAssignRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @Description TODO
 * @Author 何俊杰
 * @Date 2023-08-29 16:56
 */
@Mapper
public interface MpAssignRecordMapper extends BaseMapper<MPTbAssignRecord> {
    @Select("select * from tb_assign_record where assign_id = #{id}")
    MPTbAssignRecord selectOnea(Long id);

	/**
	 * 根据活动id查询创建人和创建id
	 * @param clueId
	 * @return
	 */
	@Select("select distinct tar.user_id userId from tb_clue c " +
			"left join tb_assign_record tar on c.create_by = tar.create_by " +
			"where tar.assign_id = #{clueId}")
	MPTbAssignRecord getUserId(Long clueId);

	/**
	 * 批量分配
	 * @param id
	 * @param userId
	 * @return
	 */
	@Update("update tb_assign_record set user_id = #{userId} where id = #{id}")
	int updateS(Long id, Long userId);
}
